package com.zhu.mqsms.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class SmsConsumer {

    private static final Logger LOGGER = LoggerFactory.getLogger(SmsConsumer.class);
    @Autowired
    private SmsService smsService;

//    @RabbitListener(queues = "smsQueue")
    @RabbitListener(queues = {"smsQueue"})
    public void receiveSmsTask( Map<String,String> map) {
        String phoneNumber = map.get("phoneNumber");
        String uniqueId = map.get("uniqueId");
        // 解析消息，获取手机号码和 UUID
        smsService.sendSms(phoneNumber, uniqueId);
    }
}